package com.meepo.usercenter

import com.meepo.basic.schema.common.PageResult
import com.meepo.basic.schema.user.User
import com.meepo.basic.schema.common.ResponseWrapper
import com.meepo.sdk.component.http.RetrofitManager
import io.reactivex.Observable
import retrofit2.http.*

/**
 * @author
 *
 * @date  2020/10/27 11:11 PM
 * @version 1.0
 */
interface API {

    companion object {
        private var sInstance: API? = null


        fun instance(): API {
            if (sInstance == null)
                sInstance = RetrofitManager.create(
                    API::class.java
                )
            return sInstance as API
        }
    }

    @POST("/api/v1/users/relations")
    fun addRelation(
        @Query("relationType") relationType: String,
        @Query("userId") userId: String
    ): Observable<ResponseWrapper<Any>>

    @DELETE("/api/v1/users/relations")
    fun deleteRelation(
        @Query("relationType") relationType: String,
        @Query("userId") userId: String
    ): Observable<ResponseWrapper<Any>>

    @PUT("/api/v1/users")
    fun updateUser(
        @Query("key") key: String = "",
        @Query("value") value: String = ""
    ): Observable<ResponseWrapper<Any>>

    @GET("/api/v1/users")
    fun getUsers(
        @Query("relationType") relationType: String = "",
        @Query("keyword") keyword: String = "",
        @Query("followUserId") followUserId: String = "",
        @Query("page") page: Int = 1,
        @Query("size") size: Int = 10
    ): Observable<ResponseWrapper<PageResult<User>>>

    @GET("/api/v1/users")
    fun getUsersV3(
        @Query("relationType") relationType: String,
        @Query("page") page: Int,
        @Query("size") size: Int
    ): Observable<ResponseWrapper<PageResult<User>>>

    @GET("/api/v1/users/{userId}")
    fun getUserInfo(
        @Path("userId") userId: String
    ): Observable<ResponseWrapper<User>>

    @POST("/api/v1/app/feedbacks")
    fun addFeedback(
        @Query("content") content: String
    ): Observable<ResponseWrapper<Any>>

}